<?php
define('SAVE_FAIL','保存数据到数据库时发生了错误');
define('UPDATE_FAIL','更新数据库发生了错误');


function getEventDao(){
    static $dao=null;
    if(!isset($dao)){
        $dao=new EventModel();
    }
    return $dao;
}

/*
 * 禁止客户端缓存
 */
function noCache(){
    header("Expires: Sat, 1 Jan 2005 00:00:00 GMT");
    header("Last-Modified: ".gmdate( "D, d M Y H:i:s")."GMT");
    header("Cache-Control: no-cache, must-revalidate, no-store");
    header("Pragma: no-cache");
    header("content-Type:text/html;charset=utf-8");
}

function getSuitableFileSize($size){
    if($size<1024){
        return $size.' B';
    }else if($size<1048576){
        return number_format($size/1024,2).' KB';
    }else{
        return number_format($size/1048576,2).' M';
    }
}

function convertFileName($filename){
    return (IS_WIN) ? auto_charset($filename,'gbk','utf-8') : $filename;
}
